﻿// uhf.h : uhf DLL 的主头文件
//

#pragma once
#include "typedef.h"

#ifdef __cplusplus
extern "C" {
#endif

#ifdef _WINDOWS
#define STD_EXPORT   __declspec(dllexport)
#else
#define STD_EXPORT
#endif

	/* libaray functions */
	STD_EXPORT int mul_loadRFIDLib(u32 *handle);
	STD_EXPORT int mul_unloadRFIDLib(void);
	STD_EXPORT int mul_setJSONMode(int listPort);
	STD_EXPORT int mul_initRFID(u32 handle, RFID_CALLBACK_FUNC pFunc, RFID_RW_CFG_CALLBACK pRWCfgFunc);
	STD_EXPORT int mul_deinitRFID(u32 handle);
	STD_EXPORT int mul_setRFModuleType(u32 handle, u8 moduleType);
	STD_EXPORT int mul_setRFConnectMode(u32 handle, u8 flag);
	STD_EXPORT int mul_powerOnRFModule(u32 handle);
	STD_EXPORT int mul_powerOffRFModule(u32 handle);
	STD_EXPORT int mul_pushRFData(u32 handle, char *rdBuf, int rdLen);
	STD_EXPORT int mul_parseRFData(u32 handle);

	STD_EXPORT int mul_openCom(u32 handle, const char* port, long baud);

	STD_EXPORT int mul_closeCom(u32 handle);

	STD_EXPORT int mul_connectRemoteNetwork(u32 handle, const char *remoteAddr, const int remotePort);
	STD_EXPORT int mul_listenRemoteNetwork(u32 handle, const int listPort);
	STD_EXPORT int mul_closeNetwork(u32 handle);

	/*
	  RF common and don't depend on actual RF moudule(R2000 AND RM8011)
	  RM70xx is virtual RF module
	*/
	STD_EXPORT int mul_setInventoryArea(u32 handle, u8 area, u8 startAddr, u8 wordLen);
    STD_EXPORT int mul_getInventoryArea(u32 handle, u8 *area, u8 *startAddr, u8 *wordLen);
	STD_EXPORT int mul_setInventoryFilterThreshold(u32 handle, u8 threshold, u16 maxRepeatTimes);
	STD_EXPORT int mul_getInventoryFilterThreshold(u32 handle, u8 *threshold, u16 *maxRepeatTimes);
	STD_EXPORT int mul_resetInventoryFilter(u32 handle);
	STD_EXPORT int mul_setAlarmParams(u32 handle, u8 mode, u8 alarmTimes, u8 ignoreSec, u8 alarmSec,
		                              u8 matchStart, u8 matchLen, u8 *match);
	STD_EXPORT int mul_getAlarmParams(u32 handle, u8 *mode, u8 *alarmTimes, u8 *ignoreSec, u8 *alarmSec,
		                              u8 *matchStart, u8 *matchLen, u8 *match);
	STD_EXPORT int mul_setAlarmStatus(u32 handle, u8 status);
	STD_EXPORT int mul_getAlarmStatus(u32 handle, u8 *status);

	/* RF common functions */
	STD_EXPORT int mul_getModuleSerialNumber(u32 handle, u8 *snData, int *snLen);
	STD_EXPORT int mul_getModuleSoftVersion(u32 handle, u8 *version, int *versionLen);
	STD_EXPORT int mul_startInventory(u32 handle, u8 mode, u8 maskFlag);
	STD_EXPORT int mul_stopInventory(u32 handle);
	STD_EXPORT int mul_getInventoryStatus(u32 handle);
	STD_EXPORT int mul_setPowerLevel(u32 handle, u8 antennaPort, u16 powerLevel);
	STD_EXPORT int mul_getPowerLevel(u32 handle, u8 antennaPort, u16 *powerLevel);

	STD_EXPORT int mul_readTag(u32 handle, u8 *accessPassword, u8 memBank, u8 startAddr, u8 wordLen);
	STD_EXPORT int mul_writeTag(u32 handle, u8 *accessPassword, u8 memBank, u8 startAddr, u8 wordLen, u8 *pWriteData);
	STD_EXPORT int mul_lockTag(u32 handle, u8 killPasswordPermissions,
		                       u8 accessPasswordPermissions,
		                       u8 epcMemoryBankPermissions, u8 tidMemoryBankPermissions,
		                       u8 userMemoryBankPermissions, u8 *accessPassword);
	STD_EXPORT int mul_killTag(u32 handle, u8 *accessPassword, u8 *killPassword);

	STD_EXPORT int mul_setRegion(u32 handle, u8 range);
	STD_EXPORT int mul_getRegion(u32 handle, u8 *range);
	STD_EXPORT int mul_setFixFreq(u32 handle, u32 freq);
	STD_EXPORT int mul_getFixFreq(u32 handle, u32 *freq);
	STD_EXPORT int mul_set18K6CSelectCriteria(u32 handle, u8 status, u8 memBank, u8 target,
		                                      u8 action, u8 enableTruncate,
		                                      u8 maskOffset, u8 maskCount, u8 *mask);
	STD_EXPORT int mul_get18K6CSelectCriteria(u32 handle, u8 *status, u8 *memBank, u8 *target,
		                                      u8 *action, u8 *enableTruncate,
		                                      u8 *maskOffset, u8 *maskCount, u8 *mask);
	STD_EXPORT int mul_getAntennaPortNum(u32 handle, u32 *num);

	/* For R2000 module and RM70xx */
    STD_EXPORT int mul_setResponseDataMode(u32 handle, u8 mode);
    STD_EXPORT int mul_getResponseDataMode(u32 handle, u8 *mode);
    STD_EXPORT int mul_getAntennaSWR(u32 handle, u32 *swr);
	STD_EXPORT int mul_setCurrentProfile(u32 handle, u32 profile);
	STD_EXPORT int mul_getCurrentProfile(u32 handle, u32 *profile);
	STD_EXPORT int mul_setAntennaPortState(u32 handle, u8 antennaPort, u8 antennaStatus);
	STD_EXPORT int mul_getAntennaPortState(u32 handle, u8 antennaPort, u8 *antennaStatus);
	STD_EXPORT int mul_setCurrentSingulationAlgorithm(u32 handle, u32 algorithm);
	STD_EXPORT int mul_getCurrentSingulationAlgorithm(u32 handle, u32 *algorithm);
	STD_EXPORT int mul_setSingulationFixedQParameters(u32 handle, u32 qValue, u32 retryCount,
		                                              u32 toggleTarget,
												      u32 repeatUntilNoTags);
	STD_EXPORT int mul_getSingulationFixedQParameters(u32 handle, u32 *qValue, u32 *retryCount,
		                                              u32 *toggleTarget,
		                                              u32 *repeatUntilNoTags);
	STD_EXPORT int mul_setSingulationDynamicQParameters(u32 handle, u32 startQValue, u32 minQValue,
		                                                u32 maxQValue,
		                                                u32 thresholdMultiplier,
		                                                u32 retryCount,
		                                                u32 toggleTarget);
	STD_EXPORT int mul_getSingulationDynamicQParameters(u32 handle, u32 *startQValue,
		                                                u32 *minQValue,
		                                                u32 *maxQValue,
		                                                u32 *thresholdMultiplier,
		                                                u32 *retryCount, u32 *toggleTarget);
	STD_EXPORT int mul_set18K6CQueryTagGroup(u32 handle, u8 selected, u8 session, u8 target);
	STD_EXPORT int mul_get18K6CQueryTagGroup(u32 handle, u8 *selected, u8 *session, u8 *target);
	STD_EXPORT int mul_setPostSingulationMatchCriteria(u32 handle, u8 status, u8 maskOffset,
		                                               u8 maskCount, u8 *mask);
	STD_EXPORT int mul_getPostSingulationMatchCriteria(u32 handle, u8 *status, u8 *maskOffset,
		                                               u8 *maskCount, u8 *mask);

	/* For R2000 four Channel module and RM70xx */
	STD_EXPORT int mul_setAntennaPort(u32 handle, u8 antennaPort, u8 antennaStatus, u32 powerLevel,
		                              u32 dwellTime, u32 numberInventoryCycles);
	STD_EXPORT int mul_getAntennaPort(u32 handle, u8 antennaPort, u8 *antennaStatus, u32 *powerLevel,
		                              u32 *dwellTime, u32 *numberInventoryCycles);

	/* For RM8011 module and RM70xx*/
	STD_EXPORT int mul_setWorkMode(u32 handle, u8 mode);
	STD_EXPORT int mul_setQuery(u32 handle, u8 DR, u8 M, u8 TRext, u8 Sel, u8 Session, u8 Target,
		                        u8 Q);
	STD_EXPORT int mul_getQuery(u32 handle, u8 *DR, u8 *M, u8 *TRext, u8 *Sel, u8 *Session, u8 *Target,
		                        u8 *Q);

	/* Only For RM70xx */
	STD_EXPORT int mul_boardFirmwareUpdate(u32 handle, u16 curIdx, u16 maxIdx, u16 dataLen, u8 *data);
	STD_EXPORT int mul_boardReboot(u32 handle);
	STD_EXPORT int mul_getBoardSerialNumber(u32 handle, u8 *snData, int *snLen);
	STD_EXPORT int mul_getBoardSoftVersion(u32 handle, u8 *version, int *versionLen);
	STD_EXPORT int mul_setBoardModuleType(u32 handle, u8 moduleType);
	STD_EXPORT int mul_getBoardModuleType(u32 handle, u8 *moduleType);
	STD_EXPORT int mul_setInventoryParams(u32 handle, u8 mode, u8 triggerDInPort, u8 triggerLevel);
	STD_EXPORT int mul_getInventoryParams(u32 handle, u8 *mode, u8 *triggerDInPort, u8 *triggerLevel);
	STD_EXPORT int mul_setHeartBeat(u32 handle, u8 status, u16 interval);
	STD_EXPORT int mul_getHeartBeat(u32 handle, u8 *status, u16 *interval);
	STD_EXPORT int mul_setNetInfo(u32 handle, u8 *ip, u8 *gateWay, u8 *netmask, u8 *macAddr,
		                          u8 *remoteIp, u16 remotePort);
	STD_EXPORT int mul_getNetInfo(u32 handle, u8 *ip, u8 *gateWay, u8 *netmask, u8 *macAddr,
		                          u8 *remoteIp, u16 *remotePort);
	STD_EXPORT int mul_setDOutStatus(u32 handle, u8 port, u8 status);
	STD_EXPORT int mul_getDOutStatus(u32 handle, u8 port, u8 *status);
	STD_EXPORT int mul_getDInStatus(u32 handle, u8 port, u8 *status);
	STD_EXPORT int mul_setAlarmDout(u32 handle, u8 port, u8 status);
	STD_EXPORT int mul_getAlarmDout(u32 handle, u8 *port, u8 *status);

#ifdef __cplusplus
}
#endif

